package region_search

import ch.hsr.geohash.GeoHash
import org.apache.spark.sql.SparkSession

object Gps2Geohash {
  def main(args: Array[String]): Unit = {

    val spark = SparkSession.builder().appName("").master("local").getOrCreate()
    import spark.implicits._
    val rdd = spark.createDataset(Seq(
      (88.12432893257,130.63591283759),
      (88.52432893257,130.93591283758)
    )
    ).rdd

    rdd.map(tp=>{
      val lat = tp._1
      val lng = tp._2
      // 变成geohash码
      val geo = GeoHash.geoHashStringWithCharacterPrecision(lat,lng,6)
      (lat,lng,geo)
    })
      .foreach(println)

    spark.close()




  }

}
